<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="../static/css/bootstrap.css" />
	<!--需要在Javascript之前引入JQuer-->
	<script type="text/javascript" src="../static/js/jquery-1.11.0.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script type="text/javascript" src="../static/js/bootstrap.js"></script>
	<!--针对移动设备的样式，为了确保适当的绘制和触屏缩放-->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!--分页css-->
	<link rel="stylesheet" href="../static/css/pagination.css">
	<!--分页js-->
	<script src="../static/js/pagination.js"></script>
	<!--jquery.cookie.js-->
	<script src="../static/js/jquery.cookie.js"></script>
</head>
	<body class="bgcolor bgcolor_open">
	<div  class="">
	<style>
		.bgcolor_open{background-color: white;}
		.bgcolor_close{background-color: #555;}
	</style>
	    <div class="row clearfix">
	        <div class="col-md-12 column">
	            <div class="row clearfix" title="top">
	                <div class="col-md-12 column">
	                	<!--头部-->
	                	<nav class="navbar-inverse container-fluid" role="navigation" style="background-color: #444;">
							<div class="container-fluid" style="padding: 0 30px 0 30px;"> 
						    <div class="navbar-header">
						        <a class="navbar-brand" href="/content/detail">
						        	<font color="#F9F9F9">留言part</font>
						        </a>
						    </div>
						    <div>
						        <!--向左对齐-->
						        <ul class="nav navbar-nav navbar-left">
						            <li class="dropdown">
						                <a href="/content/detail" class="dropdown-toggle" >
						                    首页
						                    <b class="caret"></b>
						                </a>
						                
						            </li>
						        </ul>
						       <!-- 向左对齐-文本-->
						        <!--向右对齐-->
						         <ul id="nav_right" class=" nav navbar-nav navbar-right">
				                    <li class="dropdown">
				                        <div class="navbar-form navbar-right" >
									        <div class="form-group">
									         <div class="input-group">
									          <input maxlength="15" size="35" type="text" class="form-control FuzzyVal" placeholder="代码改变世界" style="border-radius:25px;">
									          <span class="input-group-btn" style="right:40px">
									          	<button onclick="Fuzzy(1)" class="btn btn-default FuzzyBtn" style="border: none;background: none;">
									          	<span class="glyphicon glyphicon-search">
									          	</span>
									            </button>
									          </span>
									          </div>
									        </div>
										</div>
										<script>
											function Fuzzy(currentPage) {
												var FuzzyVal = $(".FuzzyVal").val();
												if (FuzzyVal != ""){
													pageSize = 4;
													offset = (currentPage - 1) * pageSize
													offset = offset < 1 ? 0 : offset;
													var messageListUrl = "/content/fuzzy?offset=" + offset + "&limit=" + pageSize+ "&value=" + FuzzyVal
													$.post(messageListUrl, function (RspData, status) {
														console.log(RspData);
														console.log(status);
														if (RspData.msgcount > 0) {
															totalPages = Math.ceil(RspData.msgcount / pageSize)
															console.log("status", totalPages)
															new Pagination({
																element: '#pages',
																type: 1,
																pageIndex: currentPage,
																pageSize: 4,
																total: RspData.msgcount,
																jumper: true,
																singlePageHide: false,
																prevText: '上一页',
																nextText: '下一页',
																disabled: true,
																currentChange: function (index) {
																	// console.log(index);
																	Fuzzy(index)
																}
															});
															$("#msglistes").empty();
															var trhtml = "";
															//获取点赞的文章数组
															var arr_M = [];
															for (var m in RspData.thumbupIdList) {
																var M_val = RspData.thumbupIdList[m].Message_id;
																arr_M.push(M_val);
															}
															for (var i in RspData.data) {

																//获取每一篇文章的点赞数
																var Num = []
																Num = jQuery.grep(arr_M, function( n, index ) {
																	return ( n == RspData.data[i].M_id);
																});
																var HeartNum = Num.length;
																//判断已点赞的文章
																// var index1 = $.inArray(RspData.data[i].M_id,arr_M);
																// if (index1 >= 0){
																// 	var heartClass='glyphicon-heart';
																// }else{
																// 	var heartClass='glyphicon-heart-empty';
																// }
																var heartClass='glyphicon-heart-empty';
																//判断登录用户与作者的用户名是否相同
																//登录用户名
																var login_username = $.cookie("login_username");
																if(RspData.data[i].Name == login_username){
																	var UpUrl ="/upmsgpage?msg_id="+RspData.data[i].M_id;
																	var BtnHtml =
																			"<a class=\"btn\" href=\""+UpUrl+"\">" +
																			"<span class=\"glyphicon glyphicon-edit\" style=\"color: rgb(0, 141, 201);\"></span>" +
																			"</a>" +
																			"<a class=\"btn\" href=\"#\"  onclick='Trash("+RspData.data[i].M_id+")'>" +
																			"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
																			"</a>" ;
																}else {
																	BtnHtml ="";
																}
																//超级用户判断
																if ("admin" == login_username){
																	BtnHtml =
																			"<a class=\"btn\" href=\"#\" onclick='Trash("+RspData.data[i].M_id+")'>" +
																			"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
																			"</a>" ;
																}
																//截取正文字符串
																var text = RspData.data[i].Text;
																if (text.length > 110){
																	text = text.slice(0,110);
																}
																//背景判断
																var bgClasslen =$(".bgcolor").attr("class").length;
																if(bgClasslen>20){
																	var bgClass = "bgcolor_close";
																}else {
																	bgClass = "bgcolor_open";
																}
																trhtml += "<!--内容列表-->" +
																		"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\" >" +
																		"<article>" +
																		"<section >" +
																		"<div >" +
																		"<h4>" +
																		"<a  href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">"+RspData.data[i].Hdline+"</a>" +
																		"</h4>" +
																		"<div class=\"row clearfix\">" +
																		"<div class=\"col-md-12 column\">" +
																		"<div class=\"media\">" +
																		"<a href=\"#\" class=\"pull-left\">" +
																		"<img src=\"../static/img/header/"+RspData.data[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
																		"</a>" +
																		"<div class=\"media-body\">" +
																		text+"......"+
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"<footer style=\"padding-top: 10px;\">" +
																		"<a href=\"#\">" +
																		"<span>"+RspData.data[i].Name +"</span>" +
																		"</a>" +
																		"<span style=\"padding-left: 10px;\">" +
																		"<span style=\"color: #777777;\">"+RspData.data[i].Cr_time +"</span>" +
																		"</span>" +
																		"<a class=\" btn \" href=\"#\" id="+'collect'+RspData.data[i].M_id+">" +
																		"<span id='"+RspData.data[i].M_id+"'  class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
																		"<span class='TmbNum'>"+HeartNum+"</span>" +
																		"</a>" +
																		"<a class=\" btn\" href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">" +
																		"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
																		"</a>" +
																		BtnHtml+
																		"<span style=\"padding-right: 10px;float: right\">" +
																		"<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+RspData.data[i].Remark +"</span></span>" +
																		"</span>" +
																		"</footer>" +
																		"</section>" +
																		"<figure>" +
																		"</figure>" +
																		"</article>" +
																		"</div>" +
																		"<!--内容列表-->"
																;
															}
															$("#msglistes").html(trhtml);
														}else {
															alert("你输入的关键字，查询不到任何东西哦！");
														}
														//点赞处理
														$(".thumbUpBtn").click(function (){
															// console.log($(this));
															// console.log($(this).attr("id"));
															$(this).toggleClass("glyphicon-heart-empty");
															$(this).toggleClass("glyphicon-heart");
															var ClassLen = $(this).attr("class").length;
															var UserId = $.cookie("userId");
															var MsgId = $(this).attr("id");
															if (ClassLen > 37){
																//数据删除
																$.ajax({
																	type: "POST",
																	url: "/deltmb",
																	data: "user_id="+UserId+"&message_id="+MsgId+"",
																	success: function(msg){
																		console.log(msg);
																		$("#"+MsgId).attr("data-content","取消点赞。");
																		$("#"+MsgId).popover('show');
																		var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
																		$("#"+MsgId).next(".TmbNum").html(tmbN);
																	}
																});
															}else {
																//数据记录
																$.ajax({
																	type: "POST",
																	url: "/tmbu",
																	data: "user_id="+UserId+"&message_id="+MsgId+"",
																	success: function(msg){
																		console.log(msg);
																		if (msg.id == 66){
																			$("#"+MsgId).attr("data-content","已点过赞了！");
																			$("#"+MsgId).popover('show');
																		}else {
																			$("#"+MsgId).attr("data-content","点赞成功！");
																			$("#"+MsgId).popover('show');
																			var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																			$("#"+MsgId).next(".TmbNum").html(tmbN);
																		}
																	}
																});
															}
															setTimeout(function () {
																$("#"+MsgId).popover('hide');
															},1000);

															//check user cookies is login or need login
															// if login , then, thumbup
															// if no login then, login window open
															// ADD thumbup or delete thumbup
															//$ajax()
														});

													});
												}
											}
										</script>
				                    </li>
				                    <li>
				                    	<a href="#" class="Inform" style="">
											<span class="badge" style='background-color: red;' ></span>
											<span  class="glyphicon glyphicon-bell" style="font-size: 18px;"></span>
				                    	</a>
				                    </li>
                                     <script>
                                         //Bell按钮
                                         Bell();
                                         function Bell() {
                                             var login_username = $.cookie("login_username");
                                             var url = "/message/listapt"
                                             $.get(url, {user_name: login_username}, function (AptData) {
												 console.log(AptData);
												 //获取点赞的文章数组
												 var arr_M = [];
												 for (var m in AptData.thumbupList) {
													 var M_val = AptData.thumbupList[m].Message_id;
													 arr_M.push(M_val);
												 }
												// console.log(arr_M)
												 var status_arr =[];
												 var staNum =[];
												 for (p in AptData.List_Apt){
													 //判断状态状态是否已查
													 var status_ = Number(AptData.List_Apt[p].Status);
													 if (status_ == 0) {
														 var msg_id = AptData.List_Apt[p].Message_id;
														 //获取每一篇文章的点赞数
														 var Num = []
														 Num = jQuery.grep(arr_M, function( n, index ) {
															 return ( n == msg_id);
														 });
														 var href="/basetext?msg_id="+msg_id+"&num="+Num.length+"";
														 $(".Inform").attr("href",href);
														 // //修改状态
														 // $.ajax({
														 //  type: "POST",
														 //  url: "http://127.0.0.1:8080/upsta",
														 //  data: {c_id: AptData.List_Apt[i].Id, sta: 1},
														 //  success: function (s) {
														 // 	 console.log("状态已经改变" + s)
														 //  }
														 // });
													 }
													 //未回复的数量
													 status_arr.push(AptData.List_Apt[p].Status);
												 }
												 staNum = jQuery.grep(status_arr, function( n, index ) {
													 return ( n == 0);
												 });
												 if (staNum.length > 0){
													 $(".badge").html(""+staNum.length+"");
												 }else {
													 $(".badge").css("display","none");
												 }

											 });

                                         }
                                     </script>
				                    <li class="dropdown">
						                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
						                    <span class="glyphicon glyphicon-user" style="font-size: 17px;"></span>
						                    <b class="caret"></b>
						                </a>
						                <ul class="dropdown-menu">
						                    <li><a onclick="MySad()"><button style="background: none; border: none">我的文章</button></a></li>
						                    <li><a href="#" onclick="PersonalInfo()">个人信息</a></li>
						                    <li><a href="/link/page">联系管理员</a></li>
						                    <li class="divider"></li>
						                    <li><a href="#" id="LoggingOut" onclick="LoggingOut()">退出登录</a></li>
						                </ul>
						            </li>
				                </ul>
						       <!-- 向右对齐-文本-->
						    </div>
							<script>
								//我的文章按钮
								function MySad() {
									//获取用户名
									var UserName = $.cookie("login_username");
									if (UserName == null){
										alert("用户已失效，请重新登录！");
										window.location.replace("/login.html");
									};
									$("#msglistes").empty();
									$("#pages").prop({
										hidden:true
									});
									var url = "/content/getlist?";
									$.get(url, {offset: 0, limit: 100 , stu: 1}, function (AllData, status) {
										console.log(AllData);
										//根据用户名筛选出指定文章的数组对象
										var TmbupData =  AllData.data.filter(function(val){return val.Name == UserName;});
										console.log(TmbupData);
										//获取点赞的文章数组
										var arr_M = [];
										for (var m in AllData.thumbupIdList) {
											var M_val = AllData.thumbupIdList[m].Message_id;
											arr_M.push(M_val);
										}
										if (TmbupData.length != 0){
											var trhtml = "";
											for (var i in TmbupData) {
												//获取每一篇文章的点赞数
												var Num = []
												Num = jQuery.grep(arr_M, function( n, index ) {
													return ( n == TmbupData[i].M_id);
												});
												//截取正文字符串
												var text = TmbupData[i].Text;
												if (text.length > 110){
													text = text.slice(0,110);
												}
												//背景判断
												var bgClasslen =$(".bgcolor").attr("class").length;
												if(bgClasslen>20){
													var bgClass = "bgcolor_close";
												}else {
													bgClass = "bgcolor_open";
												}
												var HeartNum = Num.length;
												var heartClass='glyphicon-heart-empty';
												trhtml += "<!--内容列表-->" +
														"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\">" +
														"<article>" +
														"<section >" +
														"<div >" +
														"<h4>" +
														"<a href=\"/basetext?msg_id="+TmbupData[i].M_id+"&num="+HeartNum+"\">"+TmbupData[i].Hdline+"</a>" +
														"</h4>" +
														"<div class=\"row clearfix\">" +
														"<div class=\"col-md-12 column\">" +
														"<div class=\"media\">" +
														"<a href=\"#\" class=\"pull-left\">" +
														"<img src=\"../static/img/header/"+TmbupData[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
														"</a>" +
														"<div class=\"media-body\">" +
														text+"......"+
														"</div>" +
														"</div>" +
														"</div>" +
														"</div>" +
														"</div>" +
														"<footer style=\"padding-top: 10px;\">" +
														"<a href=\"#\">" +
														"<span>"+TmbupData[i].Name +"</span>" +
														"</a>" +
														"<span style=\"padding-left: 10px;\">" +
														"<span style=\"color: #777777;\">"+TmbupData[i].Cr_time +"</span>" +
														"</span>" +
														"<a class=\" btn \" href=\"#\" id="+'collect'+TmbupData[i].M_id+">" +
														"<span id='"+TmbupData[i].M_id+"' class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
														"<span class='TmbNum'>"+HeartNum+"</span>" +
														"</a>" +
														"<a class=\" btn\" href=\"/basetext?msg_id="+TmbupData[i].M_id+"&num="+HeartNum+"\">" +
														"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
														"</a>" +
														"<a class=\"btn\" href=\"/upmsgpage?msg_id="+TmbupData[i].M_id+"\" >" +
														"<span class=\"glyphicon glyphicon-edit\" style=\"color: rgb(0, 141, 201);\"></span>" +
														"</a>" +
														"<a class=\"btn\" href=\"#\" onclick='Trash("+TmbupData[i].M_id+")'>" +
														"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
														"</a>" +
                                                        "<span style=\"padding-right: 10px;float: right\">" +
                                                        "<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+TmbupData[i].Remark +"</span></span>" +
                                                        "</span>" +
														"<span id=\"tmbhint\"></span>"+
														"</footer>" +
														"</section>" +
														"<figure>" +
														"</figure>" +
														"</article>" +
														"</div>" +
														"<!--内容列表-->"
												;

											}
											$("#msglistes").html(trhtml);
											//点赞处理
											$(".thumbUpBtn").click(function (){
												// console.log($(this));
												// console.log($(this).attr("id"));
												$(this).toggleClass("glyphicon-heart-empty");
												$(this).toggleClass("glyphicon-heart");
												var ClassLen = $(this).attr("class").length;
												var UserId = $.cookie("userId");
												var MsgId = $(this).attr("id");
												if (ClassLen > 37){
													//数据删除
													$.ajax({
														type: "POST",
														url: "/deltmb",
														data: "user_id="+UserId+"&message_id="+MsgId+"",
														success: function(msg){
															console.log(msg);
															$("#"+MsgId).attr("data-content","取消点赞。");
															$("#"+MsgId).popover('show');
															var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
															$("#"+MsgId).next(".TmbNum").html(tmbN);
														}
													});
												}else {
													//数据记录
													$.ajax({
														type: "POST",
														url: "/tmbu",
														data: "user_id="+UserId+"&message_id="+MsgId+"",
														success: function(msg){
															console.log(msg);
															if (msg.id == 66){
																$("#"+MsgId).attr("data-content","已点过赞了！");
																$("#"+MsgId).popover('show');
															}else {
																$("#"+MsgId).attr("data-content","点赞成功！");
																$("#"+MsgId).popover('show');
																var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																$("#"+MsgId).next(".TmbNum").html(tmbN);
															}
														}
													});
												}
												setTimeout(function () {
													$("#"+MsgId).popover('hide');
												},1000);

												//check user cookies is login or need login
												// if login , then, thumbup
												// if no login then, login window open
												// ADD thumbup or delete thumbup
												//$ajax()
											});
										}else {
											$("#msglistes").html("<h3 style='color: #3e8f3e;padding: 200px 600px;'>此处空空如也，快去留言吧......</h3>");
										}

									});

								};
								//个人资料按钮
								function PersonalInfo() {
									var userId = $.cookie("userId");
									var href = "/user?status=1&id=" + userId;
									window.location.replace(href);
								}
								//退出登录
								function LoggingOut() {
									$.cookie("userId","null")
									$.removeCookie("userId");
									$.removeCookie('headpic');
									$.removeCookie('login_username');
									$.removeCookie('aut_name');
									$.removeCookie('msg_id');
									$.removeCookie('num');
									$.removeCookie('Status');
									// $.cookie('userId', null);
									setTimeout(function () {
										window.location.replace("/login"); //刷新当前页面.
									},500)
								}
							</script>
							</div>
						</nav>
						<!--头部-->
	                </div>
	            </div>
	            <div class="row clearfix" title="top_img">
					<div class="col-md-12 column">
						<img src="../static/img/top_img.png" width="100%" height="30px" />
					</div>
				</div>
	            <div class="row clearfix" title="main">
					<div class="col-md-12 column">
						<div class="row clearfix" title="main_body">
							<div class="col-md-1 column" title="main_left">
								<div style="padding-top: 30px">
									<center>
										<div class="btn-group-vertical" >
											<button type="button" class="btn btn-default " style="border: none;background: none;">
												<a href="/content/detail">
													<span class="glyphicon glyphicon-home" style="color: rgb(0, 0, 0); font-size: 10px;"> 全部</span>
												</a>
											</button>
											<button type="button" class="btn btn-default " style="border: none;background: none;">
												<a href="/content/addpage">
													<span class="glyphicon glyphicon-plus" style="color: rgb(0, 0, 0); font-size: 10px;"> 发文</span>
												</a>
											</button>
											<button type="button" class="btn btn-default " style="border: none;background: none;">
												<a onclick="MyRmk()">
													<span class="glyphicon glyphicon-book" style="color: rgb(0, 0, 0); font-size: 10px;"> 我评</span>
												</a>
											</button>

											<button type="button" class="btn btn-default " style="border: none;background: none;">
												<a onclick="MyTmb()">
													<span class="glyphicon glyphicon-heart mytmb" style="color: rgb(0, 0, 0); font-size: 10px;"> 我赞</span>
												</a>
											</button>
											<br />
											<div class="btn-group-vertical">
												<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="border: none;background: none;">
													更多
													<span class="caret"></span>
												</button>
												<ul class="dropdown-menu" style="min-width: 110px">
													<li>
														<a onclick="Newest(1)"><button style="background: none; border: none">最新文章</button></a>
													</li>
													<li>
														<a onclick="BgColor()"><button id="BgSwitch" style="background: none; border: none">关灯（夜）</button></a>
													</li>
													<li class="divider"></li>
													<li id="su_u" class="">
														<a href="">用户管理</a>
													</li>
													<li id="su_m" class="">
														<a href="">文章管理</a>
													</li>
												</ul>
											</div>
											<script>
												//我评按钮
												function MyRmk() {
													$("#msglistes").empty();
													$("#pages").prop({
														hidden:true
													});
													//我评过的文章的数组Id
													var send_name = $.cookie("login_username");
													var url = "/message/list/byname"
													$.get(url, {send_name: send_name}, function (CriData,Sta) {
														var Mid = [];
														for (s in CriData.ListMId){
															var id = CriData.ListMId[s].Message_id;
															Mid.push(id);
														}
														var url = "/content/getlist?";
														$.get(url, {offset: 0, limit: 100 , stu: 1}, function (AllData, status) {
															//根据文章Id筛选出指定的被点赞文章的数组对象
															var RmkData = AllData.data.filter((a)=>{
																return Mid.some(f=>(f === a.M_id))
															})
															console.log(RmkData);
															//获取点赞的文章数组
															var arr_M = [];
															for (var m in AllData.thumbupIdList) {
																var M_val = AllData.thumbupIdList[m].Message_id;
																arr_M.push(M_val);
															}
															if (RmkData.length != 0){
																var trhtml = "";
																for (var i in RmkData) {
																	//获取每一篇文章的点赞数
																	var Num = []
																	Num = jQuery.grep(arr_M, function( n, index ) {
																		return ( n == RmkData[i].M_id);
																	});
																	//判断登录用户与作者的用户名是否相同
																	//登录用户名
																	var login_username = $.cookie("login_username");
																	//截取正文字符串
																	var text = RmkData[i].Text;
																	if (text.length > 110){
																		text = text.slice(0,110);
																	}
																	//背景判断
																	var bgClasslen =$(".bgcolor").attr("class").length;
																	if(bgClasslen>20){
																		var bgClass = "bgcolor_close";
																	}else {
																		bgClass = "bgcolor_open";
																	}
																	var HeartNum = Num.length;
																	var heartClass='glyphicon-heart';
																	trhtml += "<!--内容列表-->" +
																			"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\">" +
																			"<article>" +
																			"<section >" +
																			"<div >" +
																			"<h4>" +
																			"<a href=\"/basetext?msg_id="+RmkData[i].M_id+"&num="+HeartNum+"\">"+RmkData[i].Hdline+"</a>" +
																			"</h4>" +
																			"<div class=\"row clearfix\">" +
																			"<div class=\"col-md-12 column\">" +
																			"<div class=\"media\">" +
																			"<a href=\"#\" class=\"pull-left\">" +
																			"<img src=\"../static/img/header/"+RmkData[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
																			"</a>" +
																			"<div class=\"media-body\">" +
																			text+"......"+
																			"</div>" +
																			"</div>" +
																			"</div>" +
																			"</div>" +
																			"</div>" +
																			"<footer style=\"padding-top: 10px;\">" +
																			"<a href=\"#\">" +
																			"<span>"+RmkData[i].Name +"</span>" +
																			"</a>" +
																			"<span style=\"padding-left: 10px;\">" +
																			"<span style=\"color: #777777;\">"+RmkData[i].Cr_time +"</span>" +
																			"</span>" +
																			"<a class=\" btn \" href=\"#\" id="+'collect'+RmkData[i].M_id+">" +
																			"<span id='"+RmkData[i].M_id+"' class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
																			"<span class='TmbNum'>"+HeartNum+"</span>" +
																			"</a>" +
																			"<a class=\" btn\" href=\"/basetext?msg_id="+RmkData[i].M_id+"&num="+HeartNum+"\">" +
																			"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
																			"</a>" +
																			"</a>" +
                                                                            "<span style=\"padding-right: 10px;float: right\">" +
                                                                            "<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+RmkData[i].Remark +"</span></span>" +
                                                                            "</span>" +
																			"<span id=\"tmbhint\"></span>"+
																			"</footer>" +
																			"</section>" +
																			"<figure>" +
																			"</figure>" +
																			"</article>" +
																			"</div>" +
																			"<!--内容列表-->"
																	;

																}
																$("#msglistes").html(trhtml);
																//点赞处理
																$(".thumbUpBtn").click(function (){
																	// console.log($(this));
																	// console.log($(this).attr("id"));
																	$(this).toggleClass("glyphicon-heart-empty");
																	$(this).toggleClass("glyphicon-heart");
																	var ClassLen = $(this).attr("class").length;
																	var UserId = $.cookie("userId");
																	var MsgId = $(this).attr("id");
																	if (ClassLen > 37){
																		//数据删除
																		$.ajax({
																			type: "POST",
																			url: "/deltmb",
																			data: "user_id="+UserId+"&message_id="+MsgId+"",
																			success: function(msg){
																				console.log(msg);
																				$("#"+MsgId).attr("data-content","取消点赞。");
																				$("#"+MsgId).popover('show');
																				var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
																				$("#"+MsgId).next(".TmbNum").html(tmbN);
																			}
																		});
																	}else {
																		//数据记录
																		$.ajax({
																			type: "POST",
																			url: "/tmbu",
																			data: "user_id="+UserId+"&message_id="+MsgId+"",
																			success: function(msg){
																				console.log(msg);
																				if (msg.id == 66){
																					$("#"+MsgId).attr("data-content","已点过赞了！");
																					$("#"+MsgId).popover('show');
																				}else {
																					$("#"+MsgId).attr("data-content","点赞成功！");
																					$("#"+MsgId).popover('show');
																					var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																					$("#"+MsgId).next(".TmbNum").html(tmbN);
																				}
																			}
																		});
																	}
																	setTimeout(function () {
																		$("#"+MsgId).popover('hide');
																	},1000);

																	//check user cookies is login or need login
																	// if login , then, thumbup
																	// if no login then, login window open
																	// ADD thumbup or delete thumbup
																	//$ajax()
																});
															}else {
																$("#msglistes").html("<h3 style='color: #3e8f3e;padding: 200px 600px;'>此处空空如也，快去评论吧......</h3>");
															}

														});

												    });
												};
												//我赞按钮
												function MyTmb() {
													$("#msglistes").empty();
													$("#pages").prop({
														hidden: true
													});
													var url = "/content/getlist?";
													$.get(url, {offset: 0, limit: 100 , stu: 1}, function (AllData, status) {
														console.log(AllData);
														//获取用户点赞的文章数组Message_id
														var arr_Mid = [];
														var UserId = $.cookie("userId");
														//根据Id筛选出指定的被点赞文章的数组Id对象
														var result = AllData.thumbupIdList.filter(function(val){return val.User_id == UserId;});
														console.log(result);
														//根据文章Id筛选出指定的被点赞文章的数组Id
														for (var t in result) {
															var val_mid = result[t].Message_id;
															arr_Mid.push(val_mid);
														}
														console.log(arr_Mid);
														//根据文章Id筛选出指定的被点赞文章的数组对象
														var TmbupData = AllData.data.filter((a)=>{
															return arr_Mid.some(f=>(f === a.M_id))
														})
														console.log(TmbupData);
														//获取点赞的文章数组
														var arr_M = [];
														for (var m in AllData.thumbupIdList) {
															var M_val = AllData.thumbupIdList[m].Message_id;
															arr_M.push(M_val);
														}
														if (TmbupData.length != 0){
															var trhtml = "";
															for (var i in TmbupData) {
																//获取每一篇文章的点赞数
																var Num = []
																Num = jQuery.grep(arr_M, function( n, index ) {
																	return ( n == TmbupData[i].M_id);
																});
																//判断登录用户与作者的用户名是否相同
																//登录用户名
																var login_username = $.cookie("login_username");
																//截取正文字符串
																var text = TmbupData[i].Text;
																if (text.length > 110){
																	text = text.slice(0,110);
																}
																//背景判断
																var bgClasslen =$(".bgcolor").attr("class").length;
																if(bgClasslen>20){
																	var bgClass = "bgcolor_close";
																}else {
																	bgClass = "bgcolor_open";
																}
																var HeartNum = Num.length;
																var heartClass='glyphicon-heart';
																trhtml += "<!--内容列表-->" +
																		"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\">" +
																		"<article>" +
																		"<section >" +
																		"<div >" +
																		"<h4>" +
																		"<a href=\"/basetext?msg_id="+TmbupData[i].M_id+"&num="+HeartNum+"\">"+TmbupData[i].Hdline+"</a>" +
																		"</h4>" +
																		"<div class=\"row clearfix\">" +
																		"<div class=\"col-md-12 column\">" +
																		"<div class=\"media\">" +
																		"<a href=\"#\" class=\"pull-left\">" +
																		"<img src=\"../static/img/header/"+TmbupData[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
																		"</a>" +
																		"<div class=\"media-body\">" +
																		text+"......"+
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"<footer style=\"padding-top: 10px;\">" +
																		"<a href=\"#\">" +
																		"<span>"+TmbupData[i].Name +"</span>" +
																		"</a>" +
																		"<span style=\"padding-left: 10px;\">" +
																		"<span style=\"color: #777777;\">"+TmbupData[i].Cr_time +"</span>" +
																		"</span>" +
																		"<a class=\" btn \" href=\"#\" id="+'collect'+TmbupData[i].M_id+">" +
																		"<span id='"+TmbupData[i].M_id+"' class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
																		"<span class='TmbNum'>"+HeartNum+"</span>" +
																		"</a>" +
																		"<a class=\" btn\" href=\"/basetext?msg_id="+TmbupData[i].M_id+"&num="+HeartNum+"\">" +
																		"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
																		"</a>" +
                                                                        "<span style=\"padding-right: 10px;float: right\">" +
                                                                        "<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+TmbupData[i].Remark +"</span></span>" +
                                                                        "</span>" +
																		"<span id=\"tmbhint\"></span>"+
																		"</footer>" +
																		"</section>" +
																		"<figure>" +
																		"</figure>" +
																		"</article>" +
																		"</div>" +
																		"<!--内容列表-->"
																;

															}
															$("#msglistes").html(trhtml);
															//点赞处理
															$(".thumbUpBtn").click(function (){
																// console.log($(this));
																// console.log($(this).attr("id"));
																$(this).toggleClass("glyphicon-heart-empty");
																$(this).toggleClass("glyphicon-heart");
																var ClassLen = $(this).attr("class").length;
																var UserId = $.cookie("userId");
																var MsgId = $(this).attr("id");
																if (ClassLen > 37){
																	//数据删除
																	$.ajax({
																		type: "POST",
																		url: "/deltmb",
																		data: "user_id="+UserId+"&message_id="+MsgId+"",
																		success: function(msg){
																			console.log(msg);
																			$("#"+MsgId).attr("data-content","取消点赞。");
																			$("#"+MsgId).popover('show');
																			var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
																			$("#"+MsgId).next(".TmbNum").html(tmbN);
																		}
																	});
																}else {
																	//数据记录
																	$.ajax({
																		type: "POST",
																		url: "/tmbu",
																		data: "user_id="+UserId+"&message_id="+MsgId+"",
																		success: function(msg){
																			console.log(msg);
																			if (msg.id == 66){
																				$("#"+MsgId).attr("data-content","已点过赞了！");
																				$("#"+MsgId).popover('show');
																			}else {
																				$("#"+MsgId).attr("data-content","点赞成功！");
																				$("#"+MsgId).popover('show');
																				var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																				$("#"+MsgId).next(".TmbNum").html(tmbN);
																			}
																		}
																	});
																}
																setTimeout(function () {
																	$("#"+MsgId).popover('hide');
																},1000);

																//check user cookies is login or need login
																// if login , then, thumbup
																// if no login then, login window open
																// ADD thumbup or delete thumbup
																//$ajax()
															});
														}else {
															$("#msglistes").html("<h3 style='color: #3e8f3e;padding: 200px 600px;'>此处空空如也,快去点赞吧......</h3>");
														}
													});
												}
                                                //最新留言按钮
												function Newest(currentPage){
													$("#msglistes").empty();
													$("#pages").prop({
														hidden: false
													});
													pageSize = 4;
													offset = (currentPage - 1) * pageSize
													offset = offset < 1 ? 0 : offset;
													var messageListUrl = "/content/nowday?offset=" + offset + "&limit=" + pageSize+ "&stu=" + 1
													$.get(messageListUrl, function (RspData, status) {
														console.log(RspData);
														console.log(status);
														if (RspData.msgcount > 0) {
															totalPages = Math.ceil(RspData.msgcount / pageSize)
															console.log("status", totalPages)
															new Pagination({
																element: '#pages',
																type: 1,
																pageIndex: currentPage,
																pageSize: 4,
																total: RspData.msgcount,
																jumper: true,
																singlePageHide: false,
																prevText: '上一页',
																nextText: '下一页',
																disabled: true,
																currentChange: function (index) {
																	// console.log(index);
																	Newest(index)
																}
															});
															var trhtml = "";
															//获取点赞的文章数组
															var arr_M = [];
															for (var m in RspData.thumbupIdList) {
																var M_val = RspData.thumbupIdList[m].Message_id;
																arr_M.push(M_val);
															}
															for (var i in RspData.data) {
																//获取每一篇文章的点赞数
																var Num = []
																Num = jQuery.grep(arr_M, function( n, index ) {
																	return ( n == RspData.data[i].M_id);
																});
																var HeartNum = Num.length;
																//判断已点赞的文章
																// var index1 = $.inArray(RspData.data[i].M_id,arr_M);
																// if (index1 >= 0){
																// 	var heartClass='glyphicon-heart';
																// }else{
																// 	var heartClass='glyphicon-heart-empty';
																// }
																var heartClass='glyphicon-heart-empty';
																//判断登录用户与作者的用户名是否相同
																//登录用户名
																var login_username = $.cookie("login_username");
																if(RspData.data[i].Name == login_username){
																	var UpUrl ="/upmsgpage?msg_id="+RspData.data[i].M_id;
																	var BtnHtml =
																			"<a class=\"btn\" href=\""+UpUrl+"\">" +
																			"<span class=\"glyphicon glyphicon-edit\" style=\"color: rgb(0, 141, 201);\"></span>" +
																			"</a>" +
																			"<a class=\"btn\" href=\"#\"  onclick='Trash("+RspData.data[i].M_id+")'>" +
																			"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
																			"</a>" ;
																}else {
																	BtnHtml = "";
																}
																//超级用户判断
																if ("admin" == login_username){
																	 BtnHtml =
																			"<a class=\"btn\" href=\"#\"  onclick='Trash("+RspData.data[i].M_id+")'>" +
																			"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
																			"</a>" ;
																}
																//截取正文字符串
																var text = RspData.data[i].Text;
																if (text.length > 110){
																	text = text.slice(0,110);
																}
																//背景判断
																var bgClasslen =$(".bgcolor").attr("class").length;
																if(bgClasslen>20){
																	var bgClass = "bgcolor_close";
																}else {
																	bgClass = "bgcolor_open";
																}
																trhtml += "<!--内容列表-->" +
																		"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\" >" +
																		"<article>" +
																		"<section >" +
																		"<div >" +
																		"<h4>" +
																		"<a  href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">"+RspData.data[i].Hdline+"</a>" +
																		"</h4>" +
																		"<div class=\"row clearfix\">" +
																		"<div class=\"col-md-12 column\">" +
																		"<div class=\"media\">" +
																		"<a href=\"#\" class=\"pull-left\">" +
																		"<img src=\"../static/img/header/"+RspData.data[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
																		"</a>" +
																		"<div class=\"media-body\">" +
																		text+"......"+
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"</div>" +
																		"<footer style=\"padding-top: 10px;\">" +
																		"<a href=\"#\">" +
																		"<span>"+RspData.data[i].Name +"</span>" +
																		"</a>" +
																		"<span style=\"padding-left: 10px;\">" +
																		"<span style=\"color: #777777;\">"+RspData.data[i].Cr_time +"</span>" +
																		"</span>" +
																		"<a class=\" btn \" href=\"#\" id="+'collect'+RspData.data[i].M_id+">" +
																		"<span id='"+RspData.data[i].M_id+"'  class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
																		"<span class='TmbNum'>"+HeartNum+"</span>" +
																		"</a>" +
																		"<a class=\" btn\" href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">" +
																		"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
																		"</a>" +
																		BtnHtml+
																		"<span style=\"padding-right: 10px;float: right\">" +
																		"<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+RspData.data[i].Remark +"</span></span>" +
																		"</span>" +
																		"</footer>" +
																		"</section>" +
																		"<figure>" +
																		"</figure>" +
																		"</article>" +
																		"</div>" +
																		"<!--内容列表-->"
																;
															}
															$("#msglistes").html(trhtml);
															//点赞处理
															$(".thumbUpBtn").click(function (){
																// console.log($(this));
																// console.log($(this).attr("id"));
																$(this).toggleClass("glyphicon-heart-empty");
																$(this).toggleClass("glyphicon-heart");
																var ClassLen = $(this).attr("class").length;
																var UserId = $.cookie("userId");
																var MsgId = $(this).attr("id");
																if (ClassLen > 37){
																	//数据删除
																	$.ajax({
																		type: "POST",
																		url: "/deltmb",
																		data: "user_id="+UserId+"&message_id="+MsgId+"",
																		success: function(msg){
																			console.log(msg);
																			$("#"+MsgId).attr("data-content","取消点赞。");
																			$("#"+MsgId).popover('show');
																			var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
																			$("#"+MsgId).next(".TmbNum").html(tmbN);
																		}
																	});
																}else {
																	//数据记录
																	$.ajax({
																		type: "POST",
																		url: "/tmbu",
																		data: "user_id="+UserId+"&message_id="+MsgId+"",
																		success: function(msg){
																			console.log(msg);
																			if (msg.id == 66){
																				$("#"+MsgId).attr("data-content","已点过赞了！");
																				$("#"+MsgId).popover('show');
																			}else {
																				$("#"+MsgId).attr("data-content","点赞成功！");
																				$("#"+MsgId).popover('show');
																				var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																				$("#"+MsgId).next(".TmbNum").html(tmbN);
																			}
																		}
																	});
																}
																setTimeout(function () {
																	$("#"+MsgId).popover('hide');
																},1000);

																//check user cookies is login or need login
																// if login , then, thumbup
																// if no login then, login window open
																// ADD thumbup or delete thumbup
																//$ajax()
															});
														}else {
															$("#msglistes").html("<h3 style='color: #3e8f3e;padding: 200px 600px;'>此处空空如也,快去留言吧......</h3>");
														}
													});

												}
												// 开灯关灯按钮
												function BgColor(){
													$(".bgcolor").toggleClass("bgcolor_open");
													$(".bgcolor").toggleClass("bgcolor_close");
													$(".bgcolor_msg").toggleClass("bgcolor_close");
													$(".bgcolor_msg").toggleClass("bgcolor_open");
													var val_len = $(".bgcolor").attr("class").length;
													if (val_len >20){
														$("#BgSwitch").html("开灯（昼）");
													}else {
														$("#BgSwitch").html("关灯（夜）");
													}
												}
												//用户管理按钮
												$(function () {
													var su = $.cookie("login_username");
													// alert(su);
													if(su === "admin"){
                                                        $("#su_u a").attr("href","/userlist/page")
                                                        $("#su_m a").attr("href","/contentlist/page")
													}else {
														$("#su_u").prop({
															hidden:true
														});
														$("#su_m").prop({
															hidden:true
														});
													}
													//关闭cookie
													// setTimeout(function(){
													// 	$.cookie("login_username",null)
													// },300000);
												});
											</script>
										</div>
									</center>
								</div>
							</div>
							<div class="col-md-9 column " title="main_conter">
								<div id="msglistes" class="list-group " style="height: auto;">
									<!--内容列表-->
									  <div class="list-group-item" style="border-left: none; border-right: none;" hidden>
										<article>
								        <section >
								            <div >
								                <h4><a  href="https://www.cnblogs.com/xiaofengzai/p/14322092.html" target="_blank">Python-Flask搭建Web项目</a></h4>
								                <div class="row clearfix">
													<div class="col-md-12 column">
														<div class="media">
															 <a href="#" class="pull-left"><img src="../static/img/header/cs40006.png" width="70px" height="70px" class="media-object" alt='' /></a>
															<div class="media-body">
																 Cras sit amet nibh libero
															</div>
														</div>
													</div>
												</div>
								            </div>
								            <footer style="padding-top: 10px;">
								                <a href="https://www.cnblogs.com/xiaofengzai/"><span>清风紫雪</span></a>
								                <span style="padding-left: 10px;">
								                    <span style="color: #777777;">2021-01-24 20:04</span>
								                </span>
								                <a class="btn" href="#">
								                     <span class="glyphicon glyphicon-thumbs-up" style="color: rgb(175, 175, 230);"></span>
								                     <span>0</span>
								                </a>
								                <a class=" btn" href="#">
								                    <span class="glyphicon glyphicon-eye-open" style="color: rgb(175, 175, 230);"></span>
								                </a>
								            </footer>
								        </section>
								        <figure>
								        </figure>
								        </article>
									  </div>
									<!--内容列表-->
							    </div>
								<div id="pages" >
								</div>
								<style>
									._page_container ._pages {
										display: inline-block;
										margin: auto;
									}
								</style>
								<script>
									//遍历全部文章
									pageAutoLoadData(1);
									function  pageAutoLoadData(currentPage) {
										$("#msglistes").empty();
										$("#pages").prop({
											hidden: false
										});
										pageSize = 4;
										offset = (currentPage - 1) * pageSize
										offset = offset < 1 ? 0 : offset;
										var messageListUrl = "/content/getlist?offset=" + offset + "&limit=" + pageSize+ "&stu=" + 1
										$.get(messageListUrl, function (RspData, status) {
											console.log(RspData);
											console.log(status);
											if (RspData.msgcount > 0) {
												totalPages = Math.ceil(RspData.msgcount / pageSize)
												console.log("status", totalPages)
												new Pagination({
													element: '#pages',
													type: 1,
													pageIndex: currentPage,
													pageSize: 4,
													total: RspData.msgcount,
													jumper: true,
													singlePageHide: false,
													prevText: '上一页',
													nextText: '下一页',
													disabled: true,
													currentChange: function (index) {
														// console.log(index);
														pageAutoLoadData(index)
													}
												});
											}
											var trhtml = "";
											//获取点赞的文章数组
											var arr_M = [];
											for (var m in RspData.thumbupIdList) {
												var M_val = RspData.thumbupIdList[m].Message_id;
												arr_M.push(M_val);
											}
											for (var i in RspData.data) {
												//获取每一篇文章的点赞数
												var Num = []
												Num = jQuery.grep(arr_M, function( n, index ) {
													return ( n == RspData.data[i].M_id);
												});
												var HeartNum = Num.length;
												//判断已点赞的文章
												// var index1 = $.inArray(RspData.data[i].M_id,arr_M);
												// if (index1 >= 0){
												// 	var heartClass='glyphicon-heart';
												// }else{
												// 	var heartClass='glyphicon-heart-empty';
												// }
												var heartClass='glyphicon-heart-empty';
												//判断登录用户与作者的用户名是否相同
												//登录用户名
												var login_username = $.cookie("login_username");
												if(RspData.data[i].Name == login_username){
													var UpUrl ="/upmsgpage?msg_id="+RspData.data[i].M_id;
													var BtnHtml =
															"<a class=\"btn\" href=\""+UpUrl+"\">" +
															"<span class=\"glyphicon glyphicon-edit\" style=\"color: rgb(0, 141, 201);\"></span>" +
															"</a>" +
															"<a class=\"btn\" href=\"#\"  onclick='Trash("+RspData.data[i].M_id+")'>" +
															"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
															"</a>" ;
												}else {
													BtnHtml ="";
												}
												//超级用户判断
												if ("admin" == login_username){
													BtnHtml =
															"<a class=\"btn\" href=\"#\" onclick='Trash("+RspData.data[i].M_id+")'>" +
															"<span class=\"glyphicon glyphicon-trash\" style=\"color: rgb(255, 140, 60);\"></span>" +
															"</a>" ;
												}
												//截取正文字符串
												var text = RspData.data[i].Text;
												if (text.length > 110){
													text = text.slice(0,110);
												}
												//背景判断
												var bgClasslen =$(".bgcolor").attr("class").length;
												if(bgClasslen>20){
													var bgClass = "bgcolor_close";
												}else {
													bgClass = "bgcolor_open";
												}
												trhtml += "<!--内容列表-->" +
														"<div class=\"list-group-item bgcolor_msg "+bgClass+"\" style=\"border-left: none; border-right: none;\" >" +
														"<article>" +
														"<section >" +
														"<div >" +
														"<h4>" +
														"<a  href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">"+RspData.data[i].Hdline+"</a>" +
														"</h4>" +
														"<div class=\"row clearfix\">" +
														"<div class=\"col-md-12 column\">" +
														"<div class=\"media\">" +
														"<a href=\"#\" class=\"pull-left\">" +
														"<img src=\"../static/img/header/"+RspData.data[i].Headpic+"\" width=\"70px\" height=\"70px\" class=\"media-object\" alt='' />" +
														"</a>" +
														"<div class=\"media-body\">" +
														text+"......"+
														"</div>" +
														"</div>" +
														"</div>" +
														"</div>" +
														"</div>" +
														"<footer style=\"padding-top: 10px;\">" +
														"<a href=\"#\">" +
														"<span>"+RspData.data[i].Name +"</span>" +
														"</a>" +
														"<span style=\"padding-left: 10px;\">" +
														"<span style=\"color: #777777;\">"+RspData.data[i].Cr_time +"</span>" +
														"</span>" +
														"<a class=\" btn \" href=\"#\" id="+'collect'+RspData.data[i].M_id+">" +
														"<span id='"+RspData.data[i].M_id+"'  class='"+heartClass+" glyphicon thumbUpBtn' style=\"color: rgb(255, 0, 0);\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"内容\"></span>" +
														"<span class='TmbNum'>"+HeartNum+"</span>" +
														"</a>" +
														"<a class=\" btn\" href=\"/basetext?msg_id="+RspData.data[i].M_id+"&num="+HeartNum+"\">" +
														"<span class=\"glyphicon glyphicon-eye-open\" style=\"color: rgb(175, 175, 230);\"></span>" +
														"</a>" +
														BtnHtml+
                                                        "<span style=\"padding-right: 10px;float: right\">" +
                                                        "<span class=\"glyphicon glyphicon-volume-up\" style=\"color: rgb(255, 0, 0);\">: <span style=\"color: rgb(0, 121, 184);\">"+RspData.data[i].Remark +"</span></span>" +
                                                        "</span>" +
														"</footer>" +
														"</section>" +
														"<figure>" +
														"</figure>" +
														"</article>" +
														"</div>" +
														"<!--内容列表-->"
												;
											}
											$("#msglistes").html(trhtml);
											//点赞处理
											$(".thumbUpBtn").click(function (){
												// console.log($(this));
												// console.log($(this).attr("id"));
												$(this).toggleClass("glyphicon-heart-empty");
												$(this).toggleClass("glyphicon-heart");
												var ClassLen = $(this).attr("class").length;
												var UserId = $.cookie("userId");
												var MsgId = $(this).attr("id");
												if (ClassLen > 37){
													//数据删除
													$.ajax({
														type: "POST",
														url: "/deltmb",
														data: "user_id="+UserId+"&message_id="+MsgId+"",
														success: function(msg){
															console.log(msg);
															$("#"+MsgId).attr("data-content","取消点赞。");
															$("#"+MsgId).popover('show');
															var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) - 1;
															$("#"+MsgId).next(".TmbNum").html(tmbN);
														}
													});
												}else {
													//数据记录
													$.ajax({
														type: "POST",
														url: "/tmbu",
														data: "user_id="+UserId+"&message_id="+MsgId+"",
														success: function(msg){
															console.log(msg);
															if (msg.id == 66){
																$("#"+MsgId).attr("data-content","已点过赞了！");
																$("#"+MsgId).popover('show');
															}else {
																$("#"+MsgId).attr("data-content","点赞成功！");
																$("#"+MsgId).popover('show');
																var tmbN = parseInt($("#"+MsgId).next(".TmbNum").html()) + 1;
																$("#"+MsgId).next(".TmbNum").html(tmbN);
															}
														}
													});
												}
												setTimeout(function () {
													$("#"+MsgId).popover('hide');
												},1000);
												
												//check user cookies is login or need login
												// if login , then, thumbup
												// if no login then, login window open
												// ADD thumbup or delete thumbup
												//$ajax()
											});

										});
									}
									//删除信息
									function Trash(id) {
										var delUrl ="/content/del?id="+id;
										$.post(delUrl,function (success) {
											alert("删除成功！");
											window.location.reload();
										})
									}
								</script>
							</div>
							<div class="col-md-2 column" title="main_right">
                               <div class="jumbotron bgcolor bgcolor_open">
									<h1>
										公告：
									</h1>
									<p>
									   <div id="myTabContent" class="tab-content">
										   <div class="tab-pane fade in active" id="home">
											   <div class="form-group" style="background-color: whitesmoke;">
												   <textarea readonly id="notice_content" class="form-control" cols="6" rows="12" placeholder="欢迎来到留言part！" style=" border-top:hidden; border-left:hidden ; border-right:hidden ;" ></textarea>
											   </div>
										   </div>
									   </div>
									</p>
								   <p id="su_btn" hidden>
									   <button onclick="Uploading()" class="btn btn-info btn-large" style="float: right; " >上传</button>
									</p>
								</div>
								<div id="su_tb" class="row-fluid" hidden>
									<div class="span12">
										<span class="nav"><h4>历史公告管理:</h4></span>
										<table class="table table-hover  table-striped" id="NoList">
											<thead>
											<tr>
												<th>
													编号
												</th>
												<th>
													公告内容
												</th>
												<th>
													公布
												</th>
												<th>
													删除
												</th>
											</tr>
											</thead>
											<tbody>
											</tbody>
										</table>
									</div>
								</div>
							</div>
							<script>
								//上传公告
								function Uploading(){
									var content= $("#notice_content").val();
									$.post("/notice/add",{content:content}, function (Success) {
                                          alert("上传成功！");
										window.location.reload();
									});
								}
								$(function () {
									$("#notice_content").css({background:"whitesmoke"});
									//超级用户判断
									var login_username = $.cookie("login_username");
									if ("admin" == login_username){
										$("#su_btn").prop({
											hidden:false
										});
										$("#su_tb").prop({
											hidden:false
										});
										$("#notice_content").prop({
											readonly:false
										});
									}
									//获取公告
									$("#NoList tbody").empty();
									var NoListUrl = "/notice/list"
									$.get(NoListUrl, function (NoData) {
										console.log(NoData);
										var trhtml =""
										for ( var i in NoData.NoticeList) {
											//显示公告
											$("#notice_content").val(NoData.NewNotice[0].Content);
											// console.log(byId2)
											//截取正文字符串
											var text = NoData.NoticeList[i].Content;
											if (text.length > 8){
												text = text.slice(0,8);
											}
											//编号
											var serial =parseInt(i)+1;
											//第一天置顶内容特别显示
											var arrowClass = "glyphicon glyphicon-arrow-up";
											if (serial == 1){
												arrowClass = "";
											}
											trhtml += "<tr id='trone'>" +
													"<td>"+serial+"</td>" +
													"<td>"+text+"...</td>" +
													"<td>"+
													"<a href='#' onclick='ArrowUp("+NoData.NoticeList[i].Id+")'>"+
													"<span class=\""+arrowClass+"\" style=\"color: rgb(89, 183, 81);\">"+
													"</span>"+
													"</a>"+
													"</td>" +
													"<td>"+
													"<a href='#' onclick='TrashNo("+NoData.NoticeList[i].Id+")'>"+
													"<span class=\"glyphicon glyphicon-trash\" style=\"color: red;\">"+
													"</span>"+
													"</a>"+
													"</td>" +
													"</tr>";
										}
										$("#NoList tbody").html(trhtml);
									});
								});
								//删除历史公告
								function TrashNo(id) {
								    var DelNoUrl = "/notice/del?id="+id;
									$.post(DelNoUrl,function () {
										alert("删除成功！");
										window.location.reload();
									})
								}
								//历史公告置顶
								function ArrowUp(id) {
									var UpNolUrl = "/notice/edit?id="+id
									$.post(UpNolUrl,function () {
										alert("置顶成功！");
										window.location.reload();
									})
								}
							</script>
						</div>
					</div>
				</div>
	            <div class="row clearfix" title="footer">
					<div class="col-md-12 column">
						<footer id="footer" class="footer">\
							<center>
				            <div id="friend_link" class="">
							    友情链接：
							    <a href="//www.vpsor.cn" target="_blank">硅云</a>
							    <a href="//aws.amazon.com" target="_blank">AWS</a>
							    <a href="//www.aliyun.com" target="_blank">阿里云</a>
							    <a href="//cloud.tencent.com" target="_blank">腾讯云</a>
							    <a href="//www.huaweicloud.com" target="_blank">华为云</a>
							    <a href="//cloud.baidu.com" target="_blank">百度云</a>
							    <a href="//www.jdcloud.com" target="_blank">京东云</a>
							    <a href="//www.163yun.com" target="_blank">网易云</a>
							    <a href="//www.yisu.com" target="_blank">亿速云</a>
							    <a href="//www.rongcloud.cn" target="_blank">融云</a>
							    <a href="//www.shanhaibi.com/" target="_blank">山海鲸可视化</a>
							    <a href="http://www.gcpowertools.com.cn" target="_blank">葡萄城控件</a>
							    <a href="//www.chinaz.com/" target="_blank">站长之家</a>
							    <a href="http://dev.yesky.com" target="_blank">天极网</a>
							    <a href="//wetest.qq.com/?from=links_cnblogs" target="_blank">腾讯WeTest</a>
							    <a href="http://www.ucancode.com/" target="_blank">工控组态源码</a>
							</div>
				            <div class="footer-splitter" style="margin-top: 10px;margin-bottom: 20px;width: 80%;height: 1px;background-color: #999;"></div>
				            </center>
				        </footer>
					</div>
				</div>
	        </div>
	    </div>
	</div>
	<script>

		$(function () {
			//发表文章成功判断
			var Addmsg = $.cookie("addmsg");
			if (Addmsg == "1"){
				$.removeCookie("addmsg");
				setTimeout(function () {
					alert("发表成功！");
					window.location.replace("/content/detail");
				},500);

			}
			//登录判断
			var u_id = $.cookie("userId");
			// alert("userid:::" + u_id.length);
			if (u_id == "null" || u_id == null) {
				window.location.replace("/login");
			}
		});
	</script>
	</body>
</html>
